#!/bin/bash
expect << EOF 
spawn  /data/redis-{{ item.port }}/bin/redis-cli --cluster create  {% for host in groups['redis-inner'] %}{{ hostvars[host]['ansible_ssh_host'] }}:{{ item.port }} {% endfor %} --cluster-replicas 1

expect "(type 'yes' to accept):"  
send "yes\r"  
expect eof;  
EOF